package cn.wolfcode.luowowo.ticket.service.impl;

import cn.wolfcode.luowowo.ticket.domain.Ticket;
import cn.wolfcode.luowowo.ticket.mapper.TicketMapper;
import cn.wolfcode.luowowo.ticket.service.ITicketService;
import com.alibaba.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class TicketServiceImpl implements ITicketService{

    @Autowired
    private TicketMapper ticketMapper;

    @Override
    public void saveOrUpdate(Ticket ticket) {
        if (ticket.getId() != null){
            ticketMapper.insert(ticket);
        }else {
            ticketMapper.updateByPrimaryKey(ticket);
        }
    }

    @Override
    public Ticket get(Long id) {
        return ticketMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Ticket> listTop4() {
        return ticketMapper.selectTop4();
    }

    @Override
    public List<Ticket> selectByDestId(Long destId) {
        return ticketMapper.selectByDestId(destId);
    }

    @Override
    public List<Ticket> list() {
        return ticketMapper.selectAll();
    }

    @Override
    public List<Ticket> selectByDestIdAndSubjectId(Long ajaxDestId, Long ajaxSubjectId) {
        return ticketMapper.selectByDestIdAndSubjectId(ajaxDestId,ajaxSubjectId);
    }
}
